from django.contrib.auth.models import User
from django.db import models

# Create your models here.
#用户资金表
class UserMoney(models.Model):
    user = models.OneToOneField(User,on_delete=models.CASCADE)
    balance = models.IntegerField(default=0)


#资金变更记录表
class MoneyChangeRecord(models.Model):
    user = models.ForeignKey(User,on_delete=models.CASCADE)
    change_money = models.DecimalField(max_digits=18,decimal_places=2,default=0)
    choices=(
        (0,'充值'),
        (1,'消费')
    )
    change_type = models.SmallIntegerField(choices=choices,default=0)
    change_time = models.DateTimeField(auto_now_add=True)
    order_no = models.CharField(max_length=100,default='')

